/**
 * 熊猫直播间初始化
 * @param page
 * @param sleep
 * @returns {Promise<void>}
 */
module.exports = async ({page, sleep}) => {
    await page.addStyleTag({
        content: `
        .player-chest-login,
        .player-chest-levelup,
        .player-app-qrcode
        #duya-header,
        #player-login-tip-wrap
            {display: none !important;}
            
        .main-wrap
            {padding-top: 0 !important;}
        `
    });
    await sleep(2000);

    await page.evaluate(() => {
        //滚动到播放器
        const $player = document.querySelector('div.room-core');
        if ($player)
            document.querySelector('#main_col').scrollTo(0, $player.getBoundingClientRect().y);

        //收起左边栏
        const $leftSide = document.querySelector('div.sidebar-show');
        if ($leftSide.style.display !== 'none')
            document.querySelector('#sidebar-hide-btn').click();

        //点击播放按钮
        const $button = document.querySelector('div.player-play-big');
        if ($button)
            $button.click();
    });

    await sleep(5000);
};